package com.talkyun.openx.server.error;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Properties;

import static com.talkyun.openx.server.helper.VersionHelper.getOpenxVersion;

public class ErrorInfo {
    private static final String OPENX_VERSION = getOpenxVersion();
    private static final Properties vars = System.getProperties();

    private int statusCode;
    private String errorMessage;
    private String errorStackTrace;

    private Request request;

    public String getEnvIdInfo() {
        StringBuilder sb = new StringBuilder();
        sb.append("OpenX(").append(OPENX_VERSION).append(")");
        sb.append(" Java(").append(vars.getProperty("java.vm.specification.version")).append(") ");
        sb.append(vars.getProperty("os.name")).append("(").append(vars.getProperty("os.version")).append(")");

        // add time string
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        sb.append(" (").append(sdf.format(new Date())).append(")");
        return sb.toString();
    }

    public void setStatusCode(int statusCode) {
        this.statusCode = statusCode;
    }

    public int getStatusCode() {
        return statusCode;
    }

    public String getErrorMessage() {
        return errorMessage;
    }

    public void setErrorMessage(String errorMessage) {
        this.errorMessage = errorMessage;
    }

    public String getErrorStackTrace() {
        return errorStackTrace;
    }

    public void setErrorStackTrace(String errorStackTrace) {
        this.errorStackTrace = errorStackTrace;
    }

    public Request getRequest() {
        return request;
    }

    public void setRequest(Request request) {
        this.request = request;
    }
}